package com.xiaobaibai.controller;

import com.alibaba.fastjson.JSON;
import com.xiaobaibai.common.response.ResponseFormat;
import com.xiaobaibai.server.dashboard.IDashboardService;
import com.xiaobaibai.vo.LoveVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Slf4j
public class DashboardController {

    @Autowired
    private IDashboardService dashboardService;

    @GetMapping("/dashboard")
    public ResponseFormat dashboard(){
        //用户量+文章量+留言量+点赞量
        //是否 新增用户 新增留言 新增点赞(点赞要传数据)
        //近7日文章的点击量(还要有日子做X轴)
        Map<String, Object> data = dashboardService.getDashboardData();
        return ResponseFormat.createSuccessResponse("首页数据获取成功",data);
    }

    @PostMapping("/receiveLove")
    public ResponseFormat receiveLove(@RequestBody String data){
        log.info(JSON.toJSONString(data));
        dashboardService.receiveLove(data);
        return ResponseFormat.createSuccessResponseOnlyMessage("接收成功");
    }

}
